//
//  LSInfoCollectDisplayListViewController.m
//  LaSaCivilAffairsDepartment
//
//  Created by 聂志康 on 2019/1/26.
//  Copyright © 2019 wpkj. All rights reserved.
//

#import "LSInfoCollectDisplayListViewController.h"
#import "LSWaitForExamineTableViewCell.h"

#import "LSOldPeopleDataCollectionViewController.h"
#import "LSSocialWorkerFoundationInfoCollectViewController.h"
#import "LSKidsLeftAtHomeFoundationInfoCollectViewController.h"

#import "LSInfoCollectDisplayListModel.h"

#define headerSearchInfoViewHeight ((40*2)+(8*3))
#define CountPerPage 10

@interface LSInfoCollectDisplayListViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UIView *headerSearchInfoView;
@property (nonatomic, strong) UITextField *nameTF;
@property (nonatomic, strong) UITextField *idcardTF;
@property (nonatomic, strong) UIButton *searchButton;
@property (nonatomic, strong) NSMutableArray *prepareToDeleteArrayM;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, assign) int tableViewPage;
@property (nonatomic, strong) NSMutableArray <NSDictionary *> *dataArrayM;
@property (nonatomic, strong) NSMutableArray <LSInfoCollectDisplayListModel *> *displayDataArrayM;
@property (nonatomic, strong) NZKNoDataView *nodataView;
@property (nonatomic, strong) NZKNetworkErrorView *networkErrorView;
@end

static NSString *LSWaitForExamineTableViewCellID = @"LSWaitForExamineTableViewCellID";

@implementation LSInfoCollectDisplayListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view addSubview:self.headerSearchInfoView];
    [self.view addSubview:self.tableView];
    [self loadData];
    _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadData)];
//    UIBarButtonItem *deleteItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"more"] style:UIBarButtonItemStylePlain target:self action:@selector(deleteItemClick)];
    UIBarButtonItem *deleteItem = [[UIBarButtonItem alloc] initWithTitle:@"删除" style:UIBarButtonItemStylePlain target:self action:@selector(deleteItemClick)];
    self.navigationItem.rightBarButtonItem = deleteItem;
}

- (void)deleteItemClick {
    if (self.prepareToDeleteArrayM.count <= 0) {
        [MBProgressHUD showTipMessageInWindow:@"您未选择任何一条数据"];
        return;
    }
    WS
    UIAlertController *deleteConfirmC = [UIAlertController alertControllerWithTitle:@"确定要删除吗？" message:nil preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSMutableString *idsM = [[NSMutableString alloc] initWithString:@""];
        for (NSString *indexRow in weakSelf.prepareToDeleteArrayM) {
            NSDictionary *dataDict = weakSelf.dataArrayM[indexRow.integerValue];
            [idsM appendFormat:@"%@,",dataDict[@"id"]];
        }
        NSString *ids = [idsM substringToIndex:idsM.length-1];
        if (self.displayTag == 0) {
            [weakSelf deleteWithURL:LSAgeingDelete ByIds:ids];
        } else if (self.displayTag == 1) {
            [weakSelf deleteWithURL:LSSocialWorkerDelete ByIds:ids];
        } else {
            [weakSelf deleteWithURL:LSLcimsDelete ByIds:ids];
        }
    }];
    [deleteConfirmC addAction:cancelAction];
    [deleteConfirmC addAction:confirmAction];
    [self presentViewController:deleteConfirmC animated:true completion:nil];
}

- (void)deleteWithURL:(NSString *)URLString ByIds:(NSString *)ids {
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:URLString param:@{@"token":[ValidateUtils validateNull:[UserInfoModel sharedInstance].token],@"ids":ids} completionHandler:^(id responseObject, NSError *connectionError) {
        if (!connectionError) {
            NSNumber *status = [responseObject objectForKey:@"status"];
            if (status.integerValue == 200) {
                [MBProgressHUD showTipMessageInWindow:[ValidateUtils validateNull:[responseObject objectForKey:@"message"]]];
                [self loadData];
            } else {
                [MBProgressHUD showTipMessageInWindow:[ValidateUtils validateNull:[responseObject objectForKey:@"message"]]];
            }
        } else {
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
    }];
}

- (void)loadData {
    self.tableViewPage = 1;
    NSDictionary *param = @{};
    if (self.displayTag == 0) {
        param = @{@"name":self.nameTF.text,@"cardNo":self.idcardTF.text,@"token":[ValidateUtils validateNull:[UserInfoModel sharedInstance].token],@"pageSize":[NSString stringWithFormat:@"%d",CountPerPage],@"curPage":[NSString stringWithFormat:@"%d",self.tableViewPage]};
    } else if (self.displayTag == 1) {
        param = @{@"name":self.nameTF.text,@"idCard":self.idcardTF.text,@"token":[ValidateUtils validateNull:[UserInfoModel sharedInstance].token],@"pageSize":[NSString stringWithFormat:@"%d",CountPerPage],@"curPage":[NSString stringWithFormat:@"%d",self.tableViewPage]};
    } else {
        param = @{@"year":self.nameTF.text,@"idCard":self.idcardTF.text,@"token":[ValidateUtils validateNull:[UserInfoModel sharedInstance].token],@"pageSize":[NSString stringWithFormat:@"%d",CountPerPage],@"curPage":[NSString stringWithFormat:@"%d",self.tableViewPage]};
    }
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:true];
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:self.URLString param:param completionHandler:^(id responseObject, NSError *connectionError) {
        [hud hideAnimated:true];
        self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
        [self.tableView.mj_header endRefreshing];
        if (!connectionError) {
            [self.prepareToDeleteArrayM removeAllObjects];
            NSArray *dataArray = [responseObject objectForKey:@"data"];
            if (dataArray && dataArray.count > 0) {
                [self.dataArrayM removeAllObjects];
                [self.displayDataArrayM removeAllObjects];
                [self.nodataView removeFromSuperview];
                [self.networkErrorView removeFromSuperview];
                self.dataArrayM = [[NSMutableArray alloc] initWithArray:dataArray];
                for (NSDictionary *dict in dataArray) {
                    LSInfoCollectDisplayListModel *model = [LSInfoCollectDisplayListModel infoCollectDisplayListModelWithDict:dict];
                    if (model) {
                        [self.displayDataArrayM addObject:model];
                    }
                }
                if (self.dataArrayM.count < self.tableViewPage*CountPerPage) {
                    [self.tableView.mj_footer endRefreshingWithNoMoreData];
                }
            } else {
                [self.dataArrayM removeAllObjects];
                [self.displayDataArrayM removeAllObjects];
                [self.tableView reloadData];
                [self.tableView.mj_footer endRefreshingWithNoMoreData];
                [self.networkErrorView removeFromSuperview];
                [self.tableView addSubview:self.nodataView];
            }
            [self.tableView reloadData];
        } else {
            [self.nodataView removeFromSuperview];
            [self.tableView addSubview:self.networkErrorView];
            self.networkErrorView.tipText = [NSString stringWithFormat:@"%@",connectionError.localizedDescription];
        }
    }];
}

- (void)loadMoreData {
    self.tableViewPage++;
    NSDictionary *param = @{};
    if (self.displayTag == 0) {
        param = @{@"name":self.nameTF.text,@"cardNo":self.idcardTF.text,@"token":[ValidateUtils validateNull:[UserInfoModel sharedInstance].token],@"pageSize":[NSString stringWithFormat:@"%d",CountPerPage],@"curPage":[NSString stringWithFormat:@"%d",self.tableViewPage]};
    } else if (self.displayTag == 1) {
        param = @{@"name":self.nameTF.text,@"idCard":self.idcardTF.text,@"token":[ValidateUtils validateNull:[UserInfoModel sharedInstance].token],@"pageSize":[NSString stringWithFormat:@"%d",CountPerPage],@"curPage":[NSString stringWithFormat:@"%d",self.tableViewPage]};
    } else {
        param = @{@"year":self.nameTF.text,@"idCard":self.idcardTF.text,@"token":[ValidateUtils validateNull:[UserInfoModel sharedInstance].token],@"pageSize":[NSString stringWithFormat:@"%d",CountPerPage],@"curPage":[NSString stringWithFormat:@"%d",self.tableViewPage]};
    }
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:self.URLString param:param completionHandler:^(id responseObject, NSError *connectionError) {
        if (!connectionError) {
            NSArray *dataArray = [responseObject objectForKey:@"data"];
            if (dataArray && dataArray.count > 0) {
                [self.dataArrayM addObjectsFromArray:dataArray];
                for (NSDictionary *dict in dataArray) {
                    LSInfoCollectDisplayListModel *model = [LSInfoCollectDisplayListModel infoCollectDisplayListModelWithDict:dict];
                    if (model) {
                        [self.displayDataArrayM addObject:model];
                    }
                }
                if (self.dataArrayM.count < self.tableViewPage*CountPerPage) {
                    [self.tableView.mj_footer endRefreshingWithNoMoreData];
                } else {
                    [self.tableView.mj_footer endRefreshing];
                }
                [self.tableView reloadData];
            } else {
                self.tableViewPage--;
                [self.tableView.mj_footer endRefreshingWithNoMoreData];
            }
        } else {
            self.tableViewPage--;
            [self.tableView.mj_footer endRefreshing];
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
    }];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.displayDataArrayM.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    LSWaitForExamineTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:LSWaitForExamineTableViewCellID forIndexPath:indexPath];
    LSInfoCollectDisplayListModel *model = self.displayDataArrayM[indexPath.section];
    cell.nameLabelText = model.name;
    NSNumber *sex;
    if (self.displayTag == 2) {
        sex = model.gender;
    } else {
        sex = model.sex;
    }
    if (![sex isKindOfClass:[NSNull class]]) {
        if ([self.contentZiDuanArray[1] isEqualToString:@"gender"]) {
            if (sex.intValue == 1) {
                cell.eventNumberLabelText = @"男";
            } else {
                cell.eventNumberLabelText = @"女";
            }
        } else {
            if (sex.intValue == 0) {
                cell.eventNumberLabelText = @"男";
            } else {
                cell.eventNumberLabelText = @"女";
            }
        }
    } else {
        cell.eventNumberLabelText = @"未知";
    }
    if (self.displayTag == 0) {
        cell.addressLabelText = model.cardNo;
    } else if (self.displayTag == 1) {
        cell.addressLabelText = model.idCard;
    } else {
        cell.addressLabelText = model.idcard;
    }
    if (model.appStatus != 0 && self.displayTag == 1) {// 是社工并且是已审核的了
        cell.isResulted = true;
    } else {
        cell.isResulted = false;
    }
    cell.selectedButton.tag = indexPath.section+TagFoundation;
    [cell.selectedButton addTarget:self action:@selector(selectedButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    cell.displayListModel = self.displayDataArrayM[indexPath.section];
    return cell;
}

- (void)selectedButtonClick:(UIButton *)button {
    NSInteger indexRow = button.tag-TagFoundation;
    if (!button.isSelected) {
        [self.prepareToDeleteArrayM removeObject:[NSString stringWithFormat:@"%ld",(long)indexRow]];
    } else {
        [self.prepareToDeleteArrayM addObject:[NSString stringWithFormat:@"%ld",(long)indexRow]];
    }
    [self.tableView reloadData];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return LSWaitForExamineTableViewCellHeight;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:true];
    WS
    if (self.displayTag == 0) {
        // 老龄人员数据详情展示
        LSOldPeopleDataCollectionViewController *oldPeopleDataCollectionVC = [[LSOldPeopleDataCollectionViewController alloc] init];
        NSDictionary *dataDict = self.dataArrayM[indexPath.section];
        oldPeopleDataCollectionVC.displayDataDict = dataDict;
        oldPeopleDataCollectionVC.isCheck = true;
        oldPeopleDataCollectionVC.refreshBlock = ^{
            [weakSelf loadData];
        };
        [self.navigationController pushViewController:oldPeopleDataCollectionVC animated:true];
    } else if (self.displayTag == 1) {
        // 社工人员数据详情展示
        LSSocialWorkerFoundationInfoCollectViewController *socialWorkerFoundationInfoCollectionVC = [[LSSocialWorkerFoundationInfoCollectViewController alloc] init];
        NSDictionary *dataDict = self.dataArrayM[indexPath.section];
        socialWorkerFoundationInfoCollectionVC.displayDataDict = dataDict;
        socialWorkerFoundationInfoCollectionVC.isCheck = true;
        if (![[ValidateUtils validateNull:dataDict[@"appStatus"]] isEqualToString:@"0"]) socialWorkerFoundationInfoCollectionVC.cannotEdit = true;
        socialWorkerFoundationInfoCollectionVC.refreshBlock = ^{
            [weakSelf loadData];
        };
        [self.navigationController pushViewController:socialWorkerFoundationInfoCollectionVC animated:true];
    } else {
        LSKidsLeftAtHomeFoundationInfoCollectViewController *kidsLeftAtHomeFoundationInfoCollectVC = [[LSKidsLeftAtHomeFoundationInfoCollectViewController alloc] init];
        NSDictionary *dataDict = self.dataArrayM[indexPath.section];
        kidsLeftAtHomeFoundationInfoCollectVC.displayDataDict = dataDict;
        kidsLeftAtHomeFoundationInfoCollectVC.isCheck = true;
        kidsLeftAtHomeFoundationInfoCollectVC.refreshBlock = ^{
            [weakSelf loadData];
        };
        [self.navigationController pushViewController:kidsLeftAtHomeFoundationInfoCollectVC animated:true];
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *sectionHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
    sectionHeaderView.backgroundColor = hexColor(EEEEEE);
    return sectionHeaderView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGFloat sectionHeaderHeight = 10;
    if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
    } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
    }
}

-(NSArray<UITableViewRowAction*>*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSDictionary *dataDict = self.dataArrayM[indexPath.section];
    if (![[ValidateUtils validateNull:dataDict[@"appStatus"]] isEqualToString:@"0"] && self.displayTag == 1) {// 是社工并且是已审核的了
        return @[];
    } else {
        WS
        UITableViewRowAction *rowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"编辑" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
            if (self.displayTag == 0) {
                // 老龄人员数据详情展示
                LSOldPeopleDataCollectionViewController *oldPeopleDataCollectionVC = [[LSOldPeopleDataCollectionViewController alloc] init];
                NSDictionary *dataDict = self.dataArrayM[indexPath.section];
                oldPeopleDataCollectionVC.jumpToEdit = true;
                oldPeopleDataCollectionVC.displayDataDict = dataDict;
                oldPeopleDataCollectionVC.isCheck = true;
                oldPeopleDataCollectionVC.refreshBlock = ^{
                    [weakSelf loadData];
                };
                [self.navigationController pushViewController:oldPeopleDataCollectionVC animated:true];
            } else if (self.displayTag == 1) {
                // 社工人员数据详情展示
                NSDictionary *dataDict = self.dataArrayM[indexPath.section];
                if (![[ValidateUtils validateNull:dataDict[@"appStatus"]] isEqualToString:@"0"]) {
                    [MBProgressHUD showTipMessageInWindow:@"不可编辑"];
                } else {
                    LSSocialWorkerFoundationInfoCollectViewController *socialWorkerFoundationInfoCollectionVC = [[LSSocialWorkerFoundationInfoCollectViewController alloc] init];
                    socialWorkerFoundationInfoCollectionVC.jumpToEdit = true;
                    socialWorkerFoundationInfoCollectionVC.displayDataDict = dataDict;
                    socialWorkerFoundationInfoCollectionVC.isCheck = true;
                    if (![[ValidateUtils validateNull:dataDict[@"appStatus"]] isEqualToString:@"0"]) socialWorkerFoundationInfoCollectionVC.cannotEdit = true;
                    socialWorkerFoundationInfoCollectionVC.refreshBlock = ^{
                        [weakSelf loadData];
                    };
                    [self.navigationController pushViewController:socialWorkerFoundationInfoCollectionVC animated:true];
                }
            } else {
                LSKidsLeftAtHomeFoundationInfoCollectViewController *kidsLeftAtHomeFoundationInfoCollectVC = [[LSKidsLeftAtHomeFoundationInfoCollectViewController alloc] init];
                NSDictionary *dataDict = self.dataArrayM[indexPath.section];
                kidsLeftAtHomeFoundationInfoCollectVC.jumpToEdit = true;
                kidsLeftAtHomeFoundationInfoCollectVC.displayDataDict = dataDict;
                kidsLeftAtHomeFoundationInfoCollectVC.isCheck = true;
                kidsLeftAtHomeFoundationInfoCollectVC.refreshBlock = ^{
                    [weakSelf loadData];
                };
                [self.navigationController pushViewController:kidsLeftAtHomeFoundationInfoCollectVC animated:true];
            }
        }];
        rowAction.backgroundColor = NAV_COLOR;
        NSArray *arr = @[rowAction];
        return arr;
    }
}

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, headerSearchInfoViewHeight, ScreenWidth, ScreenHeight-SafeAreaTopHeight - headerSearchInfoViewHeight)];
        _tableView.backgroundColor = hexColor(EEEEEE);
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = [UIView new];
        [_tableView registerClass:LSWaitForExamineTableViewCell.class forCellReuseIdentifier:LSWaitForExamineTableViewCellID];
    }
    return _tableView;
}

- (UIView *)headerSearchInfoView {
    if (!_headerSearchInfoView) {
        _headerSearchInfoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, headerSearchInfoViewHeight)];
        _headerSearchInfoView.backgroundColor = UIColor.whiteColor;
        [_headerSearchInfoView addSubview:self.nameTF];
        [_headerSearchInfoView addSubview:self.idcardTF];
        [_headerSearchInfoView addSubview:self.searchButton];
    }
    return _headerSearchInfoView;
}

- (UITextField *)nameTF {
    if (!_nameTF) {
        _nameTF = [[UITextField alloc] initWithFrame:CGRectMake(15, 8, ScreenWidth-30, 40)];
        _nameTF.font = [UIFont fontWithName:@"SourceHanSansCN-Regular"  size:14];
        _nameTF.placeholder = self.searchPlaceholder;
        _nameTF.layer.borderColor = hexColor(dbdbdb).CGColor;
        _nameTF.layer.borderWidth = 1;
        UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 1)];
        leftView.backgroundColor  =UIColor.whiteColor;
        _nameTF.leftView = leftView;
        _nameTF.leftViewMode = UITextFieldViewModeAlways;
    }
    return _nameTF;
}

- (UITextField *)idcardTF {
    if (!_idcardTF) {
        _idcardTF = [[UITextField alloc] initWithFrame:CGRectMake(15, 48+8, ScreenWidth-30-50-15, 40)];
        _idcardTF.font = [UIFont fontWithName:@"SourceHanSansCN-Regular"  size:14];
        _idcardTF.placeholder = @"请输入身份证号";
        _idcardTF.layer.borderColor = hexColor(dbdbdb).CGColor;
        _idcardTF.layer.borderWidth = 1;
        UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 1)];
        leftView.backgroundColor  =UIColor.whiteColor;
        _idcardTF.leftView = leftView;
        _idcardTF.leftViewMode = UITextFieldViewModeAlways;
    }
    return _idcardTF;
}

- (UIButton *)searchButton {
    if (!_searchButton) {
        _searchButton = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-15-50, 48+8, 50, 40)];
        _searchButton.layer.cornerRadius = 4;
        _searchButton.layer.masksToBounds = true;
        _searchButton.titleLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Regular"  size:14];
        [_searchButton setTitle:@"搜索" forState:UIControlStateNormal];
        [_searchButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
        [_searchButton setBackgroundColor:NAV_COLOR];
        [_searchButton addTarget:self action:@selector(loadData) forControlEvents:UIControlEventTouchUpInside];
    }
    return _searchButton;
}

- (NSMutableArray<NSDictionary *> *)dataArrayM {
    if (!_dataArrayM) {
        _dataArrayM = [[NSMutableArray alloc] init];
    }
    return _dataArrayM;
}

- (NSMutableArray<NSDictionary *> *)prepareToDeleteArrayM {
    if (!_prepareToDeleteArrayM) {
        _prepareToDeleteArrayM = [[NSMutableArray alloc] init];
    }
    return _prepareToDeleteArrayM;
}

- (NSMutableArray<LSInfoCollectDisplayListModel *> *)displayDataArrayM {
    if (!_displayDataArrayM) {
        _displayDataArrayM = [[NSMutableArray alloc] init];
    }
    return _displayDataArrayM;
}

- (void)setContentZiDuanArray:(NSArray *)contentZiDuanArray {
    _contentZiDuanArray = contentZiDuanArray;
}

- (NZKNoDataView *)nodataView {
    if (!_nodataView) {
        _nodataView = [[NZKNoDataView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-SafeAreaTopHeight-headerSearchInfoViewHeight) withTip:@"暂无相关信息" andButtonText:nil];
    }
    return _nodataView;
}

- (NZKNetworkErrorView *)networkErrorView {
    if (!_networkErrorView) {
        WS
        _networkErrorView = [[NZKNetworkErrorView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-SafeAreaTopHeight-headerSearchInfoViewHeight) withRefreshBlock:^{
            [weakSelf loadData];
        }];
    }
    return _networkErrorView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
